<%@page contentType="text/html;charset=utf-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:useBean id="studentInfo" class="top.zerozoo.learn.grade.vo.StudentInfo" scope="request"/>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>学生成绩管理系统 - 学生信息</title>

    <link href="css/global.css" rel="stylesheet">
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <script src="js/jquery-2.1.0.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
    <div style="text-align: center;"><h3>学生信息</h3></div>
    <c:if test="${not empty error_msg}">
        <script>alert("${error_msg}");
        window.close();</script>
    </c:if>
    <ul id="myTab" class="nav nav-tabs">
        <li class="active"><a href="#info" data-toggle="tab">个人信息</a></li>
        <li><a href="#courseScore" data-toggle="tab">课程成绩</a></li>
    </ul>

    <div id="myTabContent" class="tab-content">
        <div class="tab-pane fade in active" id="info">
            <div class="panel panel-default">
                <table class="table table-striped">
                    <tr>
                        <td>学号</td>
                        <td>${studentInfo.id}</td>
                    </tr>
                    <tr>
                        <td>姓名</td>
                        <td>${studentInfo.name}</td>
                    </tr>
                    <tr>
                        <td>性别</td>
                        <td>${studentInfo.sex}</td>
                    </tr>
                    <tr>
                        <td>生日</td>
                        <td>${studentInfo.birthday}</td>
                    </tr>
                    <tr>
                        <td>住址</td>
                        <td>${studentInfo.address}</td>
                    </tr>
                    <tr>
                        <td>电话</td>
                        <td>${studentInfo.phone}</td>
                    </tr>
                    <tr>
                        <td>身份证号</td>
                        <td>${studentInfo.idcard}</td>
                    </tr>
                    <tr>
                        <td>专业</td>
                        <td>${studentInfo.major.name}</td>
                    </tr>
                </table>
                <div class="action-bar mb10 mt10">
                    <div class="form-group" style="text-align: center">
                        <a class="btn btn-warning" href="studentEdit.do?id=${studentInfo.id}">修改</a>
                    </div>
                </div>
            </div>
        </div>
        <div class="tab-pane fade" id="courseScore">
            <div class="panel panel-default">
                <table class="table table-bordered table-hover">
                    <tr class="success">
                        <th>课程名称</th>
                        <th>成绩</th>
                        <th>操作</th>
                    </tr>
                    <c:forEach items="${courseScores}" var="course" varStatus="status">
                        <tr>
                            <td>${course.name}</td>
                            <td>${course.score}</td>
                            <td>
                                <a class="btn btn-default btn-sm" href="javascript:removeScore(${course.id})">删除</a>
                            </td>
                        </tr>
                    </c:forEach>
                </table>
                <div class="action-bar mb10 mt10">
                    <div class="form-group" style="text-align: center">
                        <a class="btn btn-warning" href="scoreAdd.do?studentID=${studentInfo.id}">添加</a>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!--按钮-->
    <div class="form-group" style="text-align: center">
        <a class="btn btn-default" href="studentList.do">返回</a>
    </div>

</div>
<script>
    function removeScore(id) {
        if (confirm("确定要删除吗？")) {
            $.ajax({
                url: '${pageContext.request.contextPath}/scoreRemove.do',
                type: 'post',
                data: {id: id},
                complete: function () {
                    location.reload()
                }
            })
        }
    }
</script>
</body>
</html>